package com.yizhuoyan.his.webapi.controller;


import com.yizhuoyan.his.ao.CheckObjectRecordAo;
import com.yizhuoyan.his.dto.CheckObjectRecordDto;
import com.yizhuoyan.his.dto.JSONResponse;
import com.yizhuoyan.his.service.doctor.outpatient.InspectionApplicationService;
import com.yizhuoyan.his.webapi.controller.admin.vo.InspectionApplicationVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@Slf4j
public class InspectionApplicationController {


    @Autowired
    InspectionApplicationService inspectionApplicationService;

    @GetMapping("/api/inspection-application/{id}")
    public ResponseEntity<InspectionApplicationVo> load(@PathVariable Long id) throws Exception {
        CheckObjectRecordDto checkObjectRecordDto = inspectionApplicationService.queryCheckProject(id);
        return ResponseEntity.ok(InspectionApplicationVo.of(checkObjectRecordDto));
    }
    @PostMapping("/api/inspection-application")
    public ResponseEntity<JSONResponse> add(CheckObjectRecordAo ao)throws Exception{
        inspectionApplicationService.addCheckProject(ao);
        return ResponseEntity.ok(JSONResponse.ok());
    }


    @DeleteMapping("/api/inspection-application/{id}")
    public  ResponseEntity<JSONResponse> delete(@PathVariable  Long id)throws Exception{
//        BigDecimal bigDecimal=new BigDecimal(id);
//        long id2 = bigDecimal.longValue();
        inspectionApplicationService.removeCheckProject(id);
        return ResponseEntity.ok(JSONResponse.ok());
    }
}
